from typing import Dict, Any, List
from .base_service_handler import BaseServiceHandler, ServiceHandlerFactory

class DatabaseServiceHandler(BaseServiceHandler):
    """数据库服务信息处理器"""
    
    def get_service_details(self, service_info: Dict[str, Any]) -> List[str]:
        """获取数据库服务的详细信息"""
        details = []
        
        # 基本信息
        if service_info.get('product'):
            details.append(f"产品: {self._safe_str(service_info['product'])}")
        if service_info.get('version'):
            details.append(f"版本: {self._safe_str(service_info['version'])}")
        if service_info.get('banner'):
            details.append(f"Banner: {self._safe_str(service_info['banner'])}")
            
        # 数据库特定信息
        if service_info.get('db_version'):
            details.append(f"数据库版本: {self._safe_str(service_info['db_version'])}")
        if service_info.get('db_type'):
            details.append(f"数据库类型: {self._safe_str(service_info['db_type'])}")
        if service_info.get('auth_method'):
            details.append(f"认证方式: {self._safe_str(service_info['auth_method'])}")
        if service_info.get('requires_ssl') is not None:
            details.append(f"SSL要求: {'是' if service_info['requires_ssl'] else '否'}")
            
        return details

# 注册数据库服务处理器
for db_type in ['mysql', 'postgresql', 'mssql', 'oracle', 'mongodb']:
    ServiceHandlerFactory.register_handler(db_type, DatabaseServiceHandler) 